//
// Created by gogoqiu on 2021/9/25.
//

#ifndef WXTEST_DH_BITMAP_BUTTON_H
#define WXTEST_DH_BITMAP_BUTTON_H


/*
 * File:   dh_bitmap_button.h
 * Author: Sai
 *
 * Created on 2009年12月29日, 下午4:08
 */

#ifndef _DH_BITMAP_BUTTON_H
#define	_DH_BITMAP_BUTTON_H

#include "wx/wx.h"

enum DhBitmapButtonStatus
{
    kDhBitmapButtonNormal,
    kDhBitmapButtonEnter,
    kDhBitmapButtonDown,
    kDhBitmapButtonUp,
    kDhBitmapButtonLeave,
    kDhBitmapButtonDClick,
    kDhBitmapButtonDisable
};

class DhBitmapButton : public wxControl
{
DECLARE_DYNAMIC_CLASS(DhBitmapButton)
DECLARE_EVENT_TABLE()
public:
    DhBitmapButton();
    virtual ~DhBitmapButton();

    DhBitmapButton(wxWindow* parent, wxWindowID id,
                   const wxPoint& pos = wxDefaultPosition,
                   const wxSize& size = wxDefaultSize,
                   long style = wxBORDER_NONE,
                   const wxValidator& validator = wxDefaultValidator);
    bool Create(wxWindow* parent, wxWindowID id,
                const wxPoint& pos = wxDefaultPosition,
                const wxSize& size = wxDefaultSize,
                long style = wxSUNKEN_BORDER,
                const wxValidator& validator = wxDefaultValidator);

    wxSize DoGetBestSize() const;
    void OnPaint(wxPaintEvent& event);
    virtual void OnEnter(wxMouseEvent& event);
    virtual void OnLeave(wxMouseEvent& event);
    virtual void OnDown(wxMouseEvent& event);
    virtual void OnDClick(wxMouseEvent& event);
    virtual void OnUp(wxMouseEvent& event);
    virtual bool Enable(bool enable = true);
    virtual bool Disable();
    /**
     * 设置正常图片
     *
     * @param bitmap
     */
    DhBitmapButton* set_normal_bitmap(wxBitmap* bitmap);

    /**
     * 1.设置按钮按下时的切换图片
     */
    DhBitmapButton* set_down_bitmap(wxBitmap* bitmap);

    /**
     * 1.设置按钮按经过时的切换图片
     */
    DhBitmapButton* set_enter_bitmap(wxBitmap* bitmap);

    /**
     * 1.设置Disable图片.
     *
     * @param bitmap
     * @return this
     */
    DhBitmapButton* set_disable_bitmap(wxBitmap* bitmap);

    DhBitmapButton* set_background(const wxBitmap& bitmap);

    bool SetBackgroundColour(const wxColour& colour);

protected:
    void DrawExistBitmap(wxDC* dc,wxBitmap* image1,wxBitmap* exist_image);

private:
    wxBitmap background_;
    bool is_used_bg_;

    wxBitmap* normal_bitmap_;
    wxBitmap* down_bitmap_;
    wxBitmap* enter_bitmap_;
    wxBitmap* disable_bitmap_;

    int button_status_;
    wxString text_;
    wxFont text_font_;

    void DrawBackground(wxDC* dc);

};
#endif	/* _DH_BITMAP_BUTTON_H */

#endif //WXTEST_DH_BITMAP_BUTTON_H
